<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "yyh_sysconfig".
 *
 * @property int $id
 * @property string $var_name 参数名
 * @property string|null $var_value 名参数值
 * @property string|null $instruction 说明
 */
class Sysconfig extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'yyh_sysconfig';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['var_name'], 'required'],
            [['instruction'], 'string'],
            [['var_name', 'var_value'], 'string', 'max' => 32],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'var_name' => '参数名',
            'var_value' => '名参数值',
            'instruction' => '说明',
        ];
    }

    public static function get_var_value($var_name){
        $var = Sysconfig::find()->where("var_name = '{$var_name}'")->one();
        if(null != $var){
            return $var->var_value;
        } else {
            return null;
        }
    }
    
}
